#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int map1[10000][10000][2];
int main() {
	int a,x,y,mapsize,sum=0;
	freopen("in.txt","r",stdin);
		cin>>mapsize;
		cin>>a;
		for(int i=0; i<a; i++) {
			scanf("%d %d",&x,&y);
			map1[x+1][y+1][0]=1;
		}
		system("clear");
		cout<<"The 0"<<endl;
		if(mapsize<10)for(int i=0;i<mapsize+1;i++) cout<<i<<" ";
			else {
				for(int i=0; i<mapsize+1;i++){
					if(i<10)cout<<i<<" ";
					else cout<<i;
			    }
			}
			cout<<endl;
			for(int i=1; i<mapsize+1; i++) {
				if(i<10)cout<<i<<" ";
				else cout<<i;
				for(int j=1; j<mapsize+1; j++) {
					if(map1[i][j][0]==1) printf("O ");
					else printf("%c ",'-');
					map1[i][j][1]=0;
				}
				printf("\n");
			}
		

		system("pause");
		
	fclose(stdin);
	return 0;
}
